package com.pioneer.user;

import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.sql.DataSource;
import javax.ejb.EJBException;
import javax.naming.NamingException;
import java.rmi.RemoteException; 
import javax.ejb.SessionBean;
import javax.naming.InitialContext;
import javax.ejb.SessionContext;
import java.util.Vector;
import java.util.Enumeration;
import java.util.Collection;
import java.util.ArrayList;

//import com.pioneer.customer.CustomerPK;

public class UserEJB implements SessionBean {
  
	//private CustomerPK customerPK;

	public String getGaryName()
	{

		String result="";
		try
		{
			//customerPK=new CustomerPK(0);
			Connection dbConnection = getDBConnection();
			Statement stat=dbConnection.createStatement();
			ResultSet rs=stat.executeQuery("SELECT * FROM a02_user");
			while (rs.next())
			{
				result=rs.getString("a02_fullname");
			}
		}
		catch (SQLException e)
		{
		}
		
		return result;
	}

        public void ejbCreate() {}
        public void ejbRemove() {}
        public void ejbActivate() {}
        public void ejbPassivate() {}
        public void setSessionContext(SessionContext sc) {}

	private Connection getDBConnection() throws SQLException {
         
        Connection connection=null;
         
        try {
            InitialContext ic = new InitialContext();
            DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/Pioneer");
			
            connection = ds.getConnection("sa","");
        
        } catch (NamingException ne) {
            throw new EJBException(ne.toString());
        } catch (SQLException se) {
            throw new EJBException(se.toString());
        }

        return connection;
    }


}